/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package controlacciones.ejb3.dao;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.Map;
import javax.annotation.Resource;
import javax.ejb.Stateless;
import javax.sql.DataSource;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.util.JRLoader;

/**
 *
 * @author Vanessa
 */
@Stateless
public class ReporteDAOBean implements ReporteDAOLocal {
    public JasperPrint generarReporte( String reporte, Map parametros ) throws SQLException, JRException {
        Connection cn = ds.getConnection();
        JasperReport report = (JasperReport) JRLoader.loadObject(getClass().getResource("/report/" + reporte));
        return JasperFillManager.fillReport( report, parametros, cn );
    }

    @Resource (name="jdbc/Comercial")
    private DataSource ds;
}
